﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OnHospitalFeeItemList.aspx.cs" Inherits="Page_Customer_OnHospitalFeeItemList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link href="../../Content/syzyy/css/mzjf/zdyitem.css" rel="stylesheet" />
    <link href="../../Content/syzyy/css/mzjf/styles.1881067e4c6ce9cef087.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-1.8.0.min.js"></script>
    <%--layui--%>
    <link href="../../layui/css/layui.css" rel="stylesheet" />
    <script src="../../layui/layui.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <title>门诊缴费</title>
    <style>
        .paymentBtn[_ngcontent-c4] {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 3rem;
            color: #000;
            line-height: 3rem;
            font-size: 1.2rem;
            background: #fff;
        }

            .paymentBtn[_ngcontent-c4] .btnRight[_ngcontent-c4] {
                float: right;
                width: 25%;
                height: 100%;
                background: #2f92fc;
                text-align: center;
                color: #fff;
                border: none;
                font-size: inherit;
            }

        .theme-tcm .btn-default {
            background-color: #a08c88 !important;
        }

        .paymentBtn[_ngcontent-c4] .btnLeft[_ngcontent-c4] {
            width: 75%;
            float: left;
            text-align: left;
            padding-left: .4rem;
            box-sizing: border-box;
        }

            .paymentBtn[_ngcontent-c4] .btnLeft[_ngcontent-c4] .priceAll[_ngcontent-c4] {
                float: right;
                margin-right: 1.6rem;
                color: red;
            }

        .theme-tcm .fc-highlight2 {
            color: #fb6e52 !important;
        }
    </style>
</head>
<body style="font-size: 36px;">
    <div _ngcontent-c0="" class="app-outer theme-tcm" id="app-outer" style="height: 100%;">
        <div _ngcontent-c24="" class="outpatient-payment-detail common-page bg-white">
            <div _ngcontent-c24="" class="detail-title bg-light-grey fs-28 fc-main bg-main-bottom-bak" style="font-size: 1.1rem;">费用明细</div>
            <div _ngcontent-c24="" class="bar-code text-center bg-white">
            </div>
            <div _ngcontent-c24="" class="bg-grey bg-light-grey" style="height: 0.7rem;">
            </div>
            <div _ngcontent-c24="" class="detail-content bg-white">
                <div _ngcontent-c24="" class="content-title fc-main line-border fc-highlight">
                    <div _ngcontent-c24="" class="inner">
                        <span _ngcontent-c24="" class="first fs-24">项目名称</span>
                        <span _ngcontent-c24="" class="second fs-24">数量</span>
                        <span _ngcontent-c24="" class="third fs-24">金额</span>

                    </div>

                </div>
                <div _ngcontent-c24="" class="content-article">
                    <div _ngcontent-c24="" class="article-inner">
                    </div>
                </div>
            </div>
        </div>
        <div _ngcontent-c4="" class="paymentBtn check-box-blue-f">
            <div _ngcontent-c4="" class="btnLeft">
                <!---->
                <span _ngcontent-c4="" class="priceAll fc-highlight2">合计:0</span>
            </div>
            <button _ngcontent-c4="" class="btnRight btn-default" onclick="callpay()">立即支付 </button>
        </div>
    </div>

    <!--// 初始化-->
    <script>
        layui.use('layer', function () {
            $(function () {
                $.post("/Handler/SyzyyHandler.ashx?Action=GetOrdInftollTwo&CardId=<%=CardID%>&PatiName=<%=PatiName%>&SerialnumberAndOrdID=<%=SerialnumberAndOrdID%>", function (data) {
                    var list = eval("(" + data + ")").List;
                    if (typeof (list) != "undefined") {
                        var html = "";
                        var totalPrice = 0;
                        for (var i = 0; i < list.length; i++) {
                            var temp = '<div _ngcontent-c24="" class="article-inner-item line-border">' +
                                            '<div _ngcontent-c24="" class="fs-28 front fc-333">{ItemName}</div>' +
                                            '<div _ngcontent-c24="" class="inner">' +
                                                '<span _ngcontent-c24="" class="first fs-24 fc-light-grey">￥{Price}</span>' +
                                                '<span _ngcontent-c24="" class="second fs-24 fc-light-grey">x{totalNum}</span>' +
                                                '<span _ngcontent-c24="" class="third fs-24">￥{totalPrice}</span>' +
                                            '</div>' +
                               '</div>';
                            html += temp.replace(/{ItemName}/, list[i].ItemName).replace(/{Price}/, list[i].PRICE)
                                        .replace(/{totalNum}/, parseFloat(list[i].UNITQUANTITY).toFixed(2)).replace(/{totalPrice}/, (parseFloat(list[i].PRICE) * parseFloat(list[i].UNITQUANTITY)).toFixed(2));

                            //totalPrice += parseFloat(list[i].PRICE) * parseFloat(list[i].UNITQUANTITY);
                        }
                        $(".article-inner").html(html);
                        $(".priceAll").text("合计:" + '<%=OrdMoney%>');

                    } else {
                        list = eval("(" + data + ")");
                        layer.alert(list.info);
                    }
                });

            })
        });
    </script>

    <script type="text/javascript">

        //调用微信JS api 支付
        function jsApiCall(wxJsApiParam) {
            $(".btnRight").text("微信支付连接中...");
            $(".btnRight").attr('disabled', true);
            var _nstr = wxJsApiParam.replace(/'/g, '"');
            WeixinJSBridge.invoke(
            'getBrandWCPayRequest', JSON.parse(_nstr),
            function (res) {
                if (res.err_msg == "get_brand_wcpay_request:ok") {
                    alert("支付成功");
                    location.href = "<%=MainUrl%>" + "/page/Customer/OnHospitalfeeHistory.aspx";
                }

                if (res.err_msg == "get_brand_wcpay_request:cancel") {
                    alert("支付取消");
                    $(".btnRight").text("立即支付");
                    $(".btnRight").attr('disabled', false);
                }
                if (res.err_msg == "get_brand_wcpay_request:fail") {
                    alert(JSON.stringify(res));
                    alert("支付失败");
                    $(".btnRight").text("支付失败");
                    $(".btnRight").attr('disabled', false);
                }
            });
        }

        function callpay() {
            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }
                else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }
            else {
            $.post("/Handler/SyzyyHandler.ashx?Action=OutHospitalPreOrderNo&CardId=<%=CardID%>&PatiName=<%=PatiName%>&SerialnumberAndOrdID=<%=SerialnumberAndOrdID%>&OpenId=<%=OpenID%>&OrdMoney=<%=OrdMoney%>&visitTime=<%=visitTime%>&OrgName=<%=OrgName%>", function (data) {
                var list = eval("(" + data + ")");
                if (list.status == "1") {
                    jsApiCall(list.info);
                }
                else {
                    layer.msg(list.info, {
                        time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        //$("#add_jzr").text("一键建卡");
                        //$("#add_jzr").css({ 'background-color': '#78B830' });
                        //$("#add_jzr").attr('disabled', false);
                    });
                }

            });

            }
        }
    </script>
</body>
</html>
